package com.iretailer.report.quartz.horizon.common;

import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @Auther: xjw
 * @Date: 2019/10/12 0012 17:00
 * @Description:
 */
public class CreatRestTemplate {
    private static RestTemplate restTemplate;

    public static synchronized RestTemplate getRestTemplate() {
        if (restTemplate == null) {
            SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
            requestFactory.setConnectTimeout(1000);// 设置超时
            requestFactory.setReadTimeout(1000);
            restTemplate = new RestTemplate(requestFactory);
            return restTemplate;
        } else {
            return restTemplate;
        }
    }
}
